
function deepCopy(target, map=new Map()){
    if(typeof target !== 'object'){
        return target;
    }
    else{
        let cloneTarget = Array.isArray(target) ? [] : {};
        if(map.get(target)){
            return map.get(target);
        }
        map.set(target, cloneTarget)
        for(let key in target){
            cloneTarget[key] = deepCopy(target[key], map);
        }
        return cloneTarget;
    }
}